package com.example.user.biz;

import com.example.user.dao.UserMapper;
import com.example.user.pojo.User;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service

public class UserBizImpl  implements UserBiz{
@Autowired
  private UserMapper userMapper;

    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public int insert(User record) {
        return this.userMapper.insert(record);
    }

    @Override
    public int insertSelective(User record) {

        return this.userMapper.insertSelective(record);
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return this.userMapper.deleteByPrimaryKey(id);
    }

    @Override
    public User selectByUserCode(String usercode) {

        return this.userMapper.selectByUserCode(usercode);
    }

    @Override
    public User selectByPrimaryKey(int id) {
        return this.userMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<User> select(int pageno) {
       PageHelper.startPage(pageno,4);
        List<User> select = this.userMapper.select();
        PageInfo<User> pageInfo = new PageInfo<>(select);
        return pageInfo;
    }

    @Override
    public int updateByPrimaryKeySelective(User record) {

        return this.userMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(User record) {
        return 0;
    }

    @Override
    public List<User> like(User user) {
        List<User> like = this.userMapper.like(user);
        System.out.println(like.size()+"%%%%%%%");
       /* PageInfo<User> pageInfo = new PageInfo<>(like);*/
        return like;
    }
}
